import {
  createBrowserRouter,
  Navigate,
  RouteObject,
  RouterProvider,
} from "react-router-dom";
import { PageLayout } from "../components/Layout";
import LoginPage from "../components/Login";
import Workspace from "../pages/homepage/workspace.tsx";
import Camera from "../pages/device/camera.tsx";
import Radar from "../pages/device/radar.tsx";
import Building from "../pages/building";
import ElderManagement from "../pages/homepage/elderManagement.tsx";
import BuildingManagement from "../pages/homepage/buildingManagement.tsx";
import UserManagement from "../pages/homepage/userManagement.tsx";
import ElderReport from "../pages/homepage/elderReport.tsx";
import Risk from "../pages/homepage/risk.tsx";
import EditBuilding from "../pages/building/editBuilding.tsx";
import VideoModal from "../pages/homepage/videoModal.tsx";

// import SystemRole from "../pages/system/role.tsx";
// import SystemUser from "../pages/system/user.tsx";

export const routes: RouteObject[] = [
  {
    path: "/auth",
    children: [
      {
        path: "login",
        element: <LoginPage />,
      },
      {
        path: "videoModal",
        element: <VideoModal />,
      },
    ],
  },
  {
    path: "/",
    element: <PageLayout />,
    children: [
      {
        path: "homepage",
        children: [
          {
            path: "index",
            element: <Workspace />,
          },
          {
            path: "seniorReport/:userId",
            element: <ElderReport />,
          },
          {
            path: "seniorManagement",
            element: <ElderManagement />,
          },
          {
            path: "buildingManagement",
            element: <BuildingManagement />,
          },
          {
            path: "userList",
            element: <UserManagement />,
          },
          {
            path: "risk",
            element: <Risk />,
          },
        ],
      },
      // {
      //   path: "system",
      //   children: [
      //     {
      //       path: "user",
      //       element: <SystemUser />,
      //     },
      //     {
      //       path: "role",
      //       element: <SystemRole />,
      //     },
      //   ],
      // },
      {
        path: "cameraManagement",
        children: [
          {
            path: "index",
            element: <Camera />,
          },

          {
            path: "radar",
            element: <Radar />,
          },
        ],
      },
      {
        path: "deviceManagement",
        children: [
          {
            path: "camera",
            element: <Camera />,
          },

          {
            path: "radar",
            element: <Radar />,
          },
        ],
      },
      {
        path: "riskManagement",
        children: [
          {
            path: "index",
            element: <Risk />,
          },
        ],
      },
      {
        path: "buildingManagement",
        children: [
          {
            path: "index",
            element: <Building />,
          },
          {
            path: "addBuilding",
            element: <EditBuilding />,
          },
          {
            path: "editBuilding/:id",
            element: <EditBuilding />,
          },
        ],
      },
      {
        path: "/",
        element: <Navigate to="/homepage/index" />,
      },
      {
        path: "*",
        element: <Navigate to="/homepage/index" />,
      },
    ],
  },
];

const router = createBrowserRouter(routes);

export const Router = () => <RouterProvider router={router} />;
